#include<iostream>
using namespace std;
class Operation{
public:
    virtual double GetResult()=0;
public:
    double a;
    double b;
};

class AddOperation: public Operation{
public:
    double GetResult() override
    {
        return a + b;
    }
};

class MulOperation: public Operation{
public:
    double GetResult() override
    {
        return a * b;
    }
};

class Factory{
public:
    virtual Operation *CreateOperation() = 0;
};

class AddFactory: public Factory {
public:
    Operation *CreateOperation() override
    {
        return new AddOperation();
    }
};
class MulFactory: public Factory {
public:
    Operation *CreateOperation() override
    {
        return new MulOperation();
    }
};

int main(int argc, char *argv[])
{
    AddFactory addFactory;
    Operation *add = addFactory.CreateOperation();
    add->a = 2;
    add->b = 3;
    cout << add->GetResult() << endl;
    delete add;

    MulFactory mulFactory;
    Operation *mul = mulFactory.CreateOperation();
    mul->a = 2;
    mul->b = 3;
    cout << mul->GetResult() << endl;

}